mui.init({
    pullRefresh : {
        container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
        down : {
            style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
            color:'#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
            height:'50px',//可选,默认50px.下拉刷新控件的高度,
            range:'100px', //可选 默认100px,控件可下拉拖拽的范围
            offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
            auto: false,//可选,默认false.首次加载自动上拉刷新一次
            callback :function () {
                memData.getUserLoginSta();
                setTimeout(function () {
                    mui('#refreshContainer').pullRefresh().endPulldownToRefresh(false);
                },600);
            }
        }
    },
	beforeback: function() {
		var parentObj = plus.webview.currentWebview().opener();
		mui.fire(parentObj, 'dataList');
		return true;
	}
});
var memData;
var flag = false;

mui.plusReady(function () {
    memData = new Vue({
        el: '#insert_login_status',
        data: {
            loginSta:0,
            login_data:'',
            vip_img:'',
            vip_in:'',
            auditStatus:'no',
        },
        mounted(){
            var self = this;
            this.getUserLoginSta();
            this.$nextTick(function () {
                self.auditStatus = plus.storage.getItem('auditStatus');
            });
            //获取版本审核状态
            getAudtitStatus(self);
        },
        methods: {
            getUserLoginSta:function(){
                var api_host = plus.storage.getItem('HOST_URL');
                var self = this;
                mui.ajax({
                    url: api_host + '/api/linxuan/user/checkLoginStatus',
                    dataType: 'json',
                    headers:{'User-Token':plus.storage.getItem('UserToken')},
                    timeout:3000,
                    type: 'get',
                    success: function (msg) {
                        if (msg.code == 1) {
                            self.loginSta = 1;
                            self.login_data = msg.data;
                            self.vip_img = getMemberVipImages(parseInt(msg.data.vip)-1);
                            self.vip_in = getMemberVipIcon(parseInt(msg.data.vip)-1);
                        } else {
                            self.loginSta = 0;
                        }
                    },
                    error: function (xhr, type, errorThrown) {
                    	var network = plus.networkinfo.getCurrentType();
                    	if (network > 1) {
				            mui.toast('登录状态请求失败请重试', {duration: '300',type:'div'});
				        }
                    }
                });
            },
            open_login_detail: function () {
                mui.openWindow({
                    url:'../../logReg/login.html',
                    createNew:false,
                    id:'loginHtml',
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                    	autoShow: false,
                    }
                });
            },
            open_set: function () {
                mui.openWindow({
                    url:'../member/set.html',
                    createNew:false,
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                    	autoShow: false,
                    }
                });
            },
            open_test: function () {
                mui.openWindow({
                    url:'../member/test.html',
                    createNew:false,
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                    	autoShow: false,
                    }
                });
            },
            open_detail:function () {
                mui.openWindow({
                    url: '../member/memberInfo.html',
                    createNew:false,
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                })
            },
            open_shoucang_list:function () {
                mui.openWindow({
                    url: '../member/collection.html',
                    createNew:false,
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                })
            },
            open_kefu:function () {
                mui.openWindow({
                    url: "../member/consultant.html",
                    createNew:false,
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                });
            },
            open_my_order:function () {
                if(this.loginSta == 1){
                    mui.openWindow({
                        url: "../member/myOrder.html",
                        createNew:false,
                        show:{
                            autoShow:true,
                            anishow: 'pop-in',
                            duration: 400
                        },
                        waiting: {
                            autoShow: false,
                        }
                    });
                }else{
                    mui.toast('您还没有登录，请登录后再试', {duration: '300',type:'div'});
                }
            },
            open_vip:function () {
                mui.openWindow({
                    url:'../member/memberVip.html',
                    createNew:false,
                    show:{
                        autoShow:true,
                        anishow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                });
            },
            contact_kefu:function () {
            	customerService();
            }
        }
    })
})

document.addEventListener("dataList", function () {
    memData.getUserLoginSta();
});


